<?php

/* @var $this SurveyUserController */
/* @var $model SurveyUser */
/* @var $form CActiveForm */
Yii :: app()->clientScript->registerScript('admin', "
	$(document).ready(function(){
		choujiang();
	})
");

$event_code = $_GET['event_code'];
?>
<!--ajax代码-->
<script type="text/javascript">
	function choujiang(){
		var code = $('#EventCustomer_event_code').val();
		if(code != 0){
			//活动管理自动抽奖
			$.get("<?php echo Yii::app()->createUrl('eventCustomer/GiftNumber'); ?>", //调用控制器action获取内容
		            { code: code},
		            function(data){
		                var options = '';
		                if(data == ""){
		                	 options += "<option value='0'><?php echo Yii::t('base','Please choose Title');?> </option>";
		                }else{
		                	 options += "<option value=" + data+ ">" + data + "</option>"; //遍历赋值
		                }
		                $("#provide_gift_number").html(options); // 数据插入到地区下拉表！
		            });
		}
		//用户调查,自动抽奖
		$('#EventCustomer_event_code').change(function(){
			var code = $('#EventCustomer_event_code').val();
			$.get("<?php echo Yii::app()->createUrl('eventCustomer/GiftNumber'); ?>", //调用控制器action获取内容
            { code: code},
            function(data){
                var options = '';
                if(data == ""){
                	 options += "<option value='0'><?php echo Yii::t('base','Please choose Title');?> </option>";
                }else{
                	 options += "<option value=" + data+ ">" + data + "</option>"; //遍历赋值
                }
                $("#provide_gift_number").html(options); // 数据插入到地区下拉表！
            });
		});
	}
</script>
<div class="form">

<?php

$form = $this->beginWidget('CActiveForm', array (
	'id' => 'survey-user-form',
	'enableAjaxValidation' => false,
	
));
?>

	<p class="note"><?php echo Yii::t('base','Fields with <span class="required">*</span> are required.');?></p>

	<?php

$errorId = $_GET['errorId'];
if ($errorId == 1) {
?>
			<p class="red"><?php echo Yii::t('base','Please Enty Draw Prize Qty');?></p>
	<?php	}elseif($errorId == 2){?>
			<p class="red"><?php echo Yii::t('base','Under the current sweepstakes without user or the user does not fill in mobile number');?></p>
	<?php }?>

	<?php echo $form->errorSummary($model); ?>

	<div class="row-fluid">					
		<div class="span6">
			<div class="form-row control-group row-fluid">
		<?php echo $form->labelEx($model,'event_code'); ?>
		<div class="controls span7">
		<?php echo $form->dropDownList($model,'event_code',EventCustomer::model()->getActivetyCodeTitle(),array('options' => array($event_code=>array('selected'=>true)))); ?>
		<?php echo $form->error($model,'event_code'); ?>
			</div>
			</div>
		</div>

	<div class="span6">
			<div class="form-row control-group row-fluid">
		<label for="SurveyUser_activety_code"><?php echo Yii::t('base','Provide Gift Number');?> <span class="required">*</span></label>
		<div class="controls span7">
		<select name="provide_gift_number" id="provide_gift_number" ></select>
		</div>
		</div>
			</div>
		</div>
	
	<div class="row-fluid">					
		<div class="span6">
			<div class="form-row control-group row-fluid">
			<label for="SurveyUser_activety_code"><?php echo Yii::t('base','Draw Prize Qty');?> <span class="required">*</span></label>
		<div class="controls span7">
		<input type="text" name="lottery_numbers" id="lottery_numbers"/>
		</div>
		</div>
			</div>
		</div>
	<div class="form-actions row-fluid">
	<div class="span7 offset3">
		<?php echo CHtml::submitButton($model->isNewRecord ? Yii::t('base','Lucky draw') : Yii::t('base','Save'),array('class'=>'btn btn-large btn-block')); ?>
		</div>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->